package Test01;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User: YKH
 * Date: 2022-05-04
 * Time: 21:51
 * author:TestPanel
 */
public class TestPanel {
    public static void main(String[] args) {
        //面板需要先有创建窗口
        Frame frame = new Frame();
        //设置布局
        frame.setLayout(null);
        //创建面板对象
        Panel panel = new Panel();

        //对 frame设置坐标,长宽 背景颜色
        frame.setBounds(200,300,500,300);
        frame.setBackground(Color.white);

        //对panel设置初始位置、坐标、颜色相对于frame
        panel.setBounds(1,1,300,200);
        panel.setBackground(new Color(1,1,1));

        frame.add(panel);
        frame.setVisible(true);
        //设置监听,关闭窗口
        frame.addWindowListener(new WindowAdapter() {
            //窗口点击时关闭窗口
            @Override
            public void windowClosing(WindowEvent e) {
                //结束程序
                System.exit(0);
            }
        });
    }
}
